package com.flyqiu.flow.api.script;

import com.alibaba.fastjson2.JSONObject;

import javax.el.ELContext;
import javax.el.ELResolver;
import java.beans.FeatureDescriptor;
import java.util.Iterator;

public class JSONObjectElResolver extends ELResolver {

    @Override
    public Class<?> getCommonPropertyType(ELContext context, Object base) {
        return null;
    }


    @Override
    public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
        return null;
    }


    @Override
    public Class<?> getType(ELContext context, Object base, Object property) {
        return null;
    }


    @Override
    public Object getValue(ELContext context, Object base, Object property) {
        if (base == null) {
            return null;
        }
        if (!(base instanceof JSONObject)) {
            return null;
        }
        return ((JSONObject) base).get((String) (property));
    }


    @Override
    public boolean isReadOnly(ELContext context, Object base, Object property) {
        return false;
    }


    @Override
    public void setValue(ELContext context, Object base, Object property, Object value) {

    }
}
